import config from '@/env/config';
import request from '@/router/axios';
const baseUrl = config.baseUrl;
const mockUrl = config.mockUrl;

export const getDic = type => request({
    url: `${baseUrl}/app/dict/${type}`,
    method: 'get',
});

export const uploadImg = (relationId, content, type, imgType) => request({
    url: `${baseUrl}/app/upload`,
    method: 'post',
    data: {
        relationId,
        file: content,
        type,
        imgType,
    },
});

export const getNews = page => request({
    url: `${baseUrl}/app/notificationInfo/index/page`,
    method: 'get',
    params: page,
});

export const getRolesList = () => new Promise((resolve) => {
    window.$.get(`${mockUrl}/yapi/rolesList`, (res) => {
        resolve({
            data: res,
        });
    });
});

export const getBanner = communityId => request({
    url: `${baseUrl}/app/showLbtApp`,
    method: 'get',
    params: {
        communityId
    },
});

export const getCommunityById = communityId => request({
    url: `${baseUrl}/app/bindOwner/getCommunityInfoById`,
    method: 'get',
    params: {
        communityId
    },
});

export const delImg = id => request({
    url: `${baseUrl}/app/repairRecord/deleteImg`,
    method: 'get',
    params: {
        id,
    },
});